package detect.parse.tree.token;

import java.util.*;

public class Keywords {
	static Keywords instance = null;
	HashMap<String,TokenType> map=new HashMap<String,TokenType>(); 
	public static Keywords instance(){		
        if (instance == null) {
            instance = new Keywords();
            //context.put(namesKey, instance);
        }
        return instance;
    }
	
	protected Keywords(){
		Class<TokenType> tokenClass=TokenType.class;
		TokenType[] tokens=tokenClass.getEnumConstants();
		
		for(int i=0;i<tokens.length;i++){
			if(tokens[i].typeStr!=null){
				map.put(tokens[i].typeStr, tokens[i]);
			}
		}
	}
	public TokenType key(Name name){
		TokenType token=map.get(name.nameStr);
		if(token!=null){
			return token;
		}
		return TokenType.IDENTIFIER;
	}
}
